
public class LogFileEntry {
	
	//all the parts of a log file entry
	private float partNo;
	private int seqNo;
	private String username;
	private int ops;
	private byte[] HMAC;
	private byte[] hash;
	
	LogFileEntry (float p, int s, String u, int o, byte[] hmac, byte[] h) {
		this.partNo = p;
		this.seqNo = s;
		this.username = u;		
		this.ops = o;
		this.HMAC = hmac;
		this.hash = h;
	}	
	
	public String returnEntry() {
		String stringOfHash = new String(hash);
		String stringOfHMAC = byteToHex(HMAC);
		return (Float.toString(partNo) + " " + Integer.toString(seqNo) + " " + username
				+ " " + Integer.toString(ops)+ " " + stringOfHMAC + " " + stringOfHash + "\n");
	}
	
    static final String HEXES = "0123456789ABCDEF";

    public String byteToHex( byte [] raw ) {
        if ( raw == null ) {
          return null;
        }
        final StringBuilder hex = new StringBuilder( 2 * raw.length );
        for ( final byte b : raw ) {
          hex.append(HEXES.charAt((b & 0xF0) >> 4))
             .append(HEXES.charAt((b & 0x0F)));
        }
        return hex.toString();
    }
    
	public float getPartNo(){
		return partNo;
	}
	
	public int getSeqNo(){
		return seqNo;
	}
	
	public int getOps(){
		return ops;
	}
	
	public byte[] getHash(){
		return hash;
	}
	
	public byte[] getHMAC(){
		return HMAC;
	}
}
